import Vue from 'vue'
Vue.use(Router)
import Router from 'vue-router'
import Login from './views/Login'
import HomeWork from  './views/HomeWork'
import GroupMember from './views/ChannelViews/GroupMember'
import GroupAdd from './views/ChannelViews/GroupAdd'
import FloodPatrol from  './views/FloodPatrol'
import FloodPatrolDetail from  './views/FloodPatrolDetail'
import InfoReport from  './views/InfoReport'
import ReportImage from  './views/ReportImage'
import ReportVideo from "./views/ReportVideo"
import ReportSound from "./views/ReportSound"
import WarnInfo from "./views/WarnInfo"
import StateSet from "./views/StateSet"
import ReportHistory from "./views/ReportHistory"
import SystemSet from "./views/SystemSet"
import LineCount from "./views/LineCount";
import MapMark from "./views/MapMark";
import VersionCheck from "./views/VersionCheck";
import AboutSoft from "./views/AboutSoft";
import LineWork from "./views/LineWork";
import LineWorkSurePlan from  "./views/LineWorkViews/LineWorkSurePlan"
import LineWorkTakePhoto from  "./views/LineWorkViews/LineWorkTakePhoto"
import LineWorkSurePerson from "./views/LineWorkViews/LineWorkSurePerson"
import LineWorkSureTool from "./views/LineWorkViews/LineWorkSureTool"
import LineWorkInto from "./views/LineWorkViews/LineWorkInto"
import LineWorkBegin from "./views/LineWorkViews/LineWorkBegin"
import LineWorkEnd from "./views/LineWorkViews/LineWorkEnd"
import LineWorkOut from "./views/LineWorkViews/LineWorkOut"
import LineWorkSureOutTool from "./views/LineWorkViews/LineWorkSureOutTool"
import LineWorkReturn from "./views/LineWorkViews/LineWorkReturn";
import LineWorkSurePhoto from "./views/LineWorkViews/LineWorkSurePhoto"
import SearchChannel from "./views/ChannelViews/SearchChannel"
import ManageChannel from "./views/ChannelViews/ManageChannel"
import Test from "./views/Test"
/*export default new Router({
  routes: [*/

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'login',
      component: Login
    },
    {
      path: '/homework',
      name: 'homework',
      component: HomeWork
    },
    {
      path: '/groupMember',
      name: 'groupMember',
      component: GroupMember
    },
    {
      path: '/groupMember/groupAdd',
      name: 'groupAdd',
      component: GroupAdd
    },
    {
      path: '/floodPatrol',
      name: 'floodPatrol',
      component: FloodPatrol
    },
    {
      path: '/floodPatrolDetail',
      name: 'floodPatrolDetail',
      component: FloodPatrolDetail
    },
    {
      path: '/floodPatrol/infoReport',
      name: 'infoReport',
      component: InfoReport
    },
    {
      path: '/floodPatrol/infoReport/reportImage',
      name: 'reportImage',
      component: ReportImage
    },
    {
      path: '/floodPatrol/infoReport/reportVideo',
      name: 'reportVideo',
      component: ReportVideo
    },
    {
      path: '/floodPatrol/infoReport/reportSound',
      name: 'reportSound',
      component: ReportSound
    },
    {
      path: '/warnInfo',
      name: 'warnInfo',
      component: WarnInfo
    },
    {
      path: '/stateSet',
      name: 'stateSet',
      component: StateSet
    },
    {
      path: '/reportHistory',
      name: 'reportHistory',
      component: ReportHistory
    },
    {
      path: '/systemSet',
      name: 'systemSet',
      component: SystemSet
    },
    {
      path: '/lineCount',
      name: 'lineCount',
      component: LineCount
    },
    {
      path: '/mapMark',
      name: 'mapMark',
      component: MapMark
    },
    {
      path: '/versionCheck',
      name: 'versionCheck',
      component: VersionCheck
    },
    {
      path: '/aboutSoft',
      name: 'aboutSoft',
      component: AboutSoft
    },
    {
      path: '/lineWork',
      name: 'lineWork',
      component: LineWork
    },
    {
      path: '/lineWork/lineWorkSurePlan',
      name: 'lineWorkSurePlan',
      component: LineWorkSurePlan
    },
    {
      path: '/lineWork/lineWorkTakePhoto',
      name: 'lineWorkTakePhoto',
      component: LineWorkTakePhoto
    },
    {
      path: '/lineWork/lineWorkSurePerson',
      name: 'lineWorkSurePerson',
      component: LineWorkSurePerson
    },
    {
      path: '/lineWork/lineWorkSureTool',
      name: 'lineWorkSureTool',
      component: LineWorkSureTool
    },
    {
      path: '/lineWork/lineWorkInto',
      name: 'lineWorkInto',
      component: LineWorkInto
    },
    {
      path: '/lineWork/lineWorkBegin',
      name: 'lineWorkBegin',
      component: LineWorkBegin
    },
    {
      path: '/lineWork/lineWorkEnd',
      name: 'lineWorkEnd',
      component: LineWorkEnd
    },
    {
      path: '/lineWork/lineWorkOut',
      name: 'lineWorkOut',
      component: LineWorkOut
    },
    {
      path: '/lineWork/lineWorkSureOutTool',
      name: 'lineWorkSureOutTool',
      component: LineWorkSureOutTool
    },
    {
      path: '/lineWork/lineWorkReturn',
      name: 'lineWorkReturn',
      component: LineWorkReturn
    },
    {
      path: '/lineWork/lineWorkSurePhoto',
      name: 'lineWorkSurePhoto',
      component: LineWorkSurePhoto
    },
    {
      path: '/test',
      name: 'test',
      component: Test
    },
    {
      path: '/searchChannel',
      name: 'searchChannel',
      component: SearchChannel
    },
    {
      path: '/manageChannel',
      name: 'manageChannel',
      component: ManageChannel
    },
  ]
});

// 导航守卫
// 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
router.beforeEach((to, from, next) => {
  if (to.path === '/') {
    next();
  } else {
    let token = localStorage.getItem('Authorization');

    if (token === 'null' || token === '') {
      next('/login');
    } else {
      next();
    }
  }
});

export default router;

